<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Nabu-asr: nabu.neuralnetworks.components.attention.WindowedAttention Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Nabu-asr
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacenabu.html">nabu</a></li><li class="navelem"><b>neuralnetworks</b></li><li class="navelem"><b>components</b></li><li class="navelem"><b>attention</b></li><li class="navelem"><a class="el" href="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1WindowedAttention.html">WindowedAttention</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1WindowedAttention-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">nabu.neuralnetworks.components.attention.WindowedAttention Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>attention mechanism that is location aware  
 <a href="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1WindowedAttention.html#details">More...</a></p>
<div class="dynheader">
Inheritance diagram for nabu.neuralnetworks.components.attention.WindowedAttention:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1WindowedAttention.png" usemap="#nabu.neuralnetworks.components.attention.WindowedAttention_map" alt=""/>
  <map id="nabu.neuralnetworks.components.attention.WindowedAttention_map" name="nabu.neuralnetworks.components.attention.WindowedAttention_map">
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader"></div></td></tr>
<tr class="memitem:ac9db812b48e8bc8d138a63ad47457493"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1WindowedAttention.html#ac9db812b48e8bc8d138a63ad47457493">__init__</a> (self, num_units, left_window_width, right_window_width, memory, memory_sequence_length=None, normalize=False, probability_fn=None, score_mask_value=float(&quot;-inf&quot;), dtype=None, name='<a class="el" href="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1LocationAwareAttention.html">LocationAwareAttention</a>')</td></tr>
<tr class="memdesc:ac9db812b48e8bc8d138a63ad47457493"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct the Attention mechanism.  <a href="#ac9db812b48e8bc8d138a63ad47457493">More...</a><br /></td></tr>
<tr class="separator:ac9db812b48e8bc8d138a63ad47457493"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a17a840d2cf3ad36cb97ae5f72ec2aae6"><td class="memItemLeft" align="right" valign="top"><a id="a17a840d2cf3ad36cb97ae5f72ec2aae6"></a>
def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1WindowedAttention.html#a17a840d2cf3ad36cb97ae5f72ec2aae6">initial_alignments</a> (self, batch_size, dtype)</td></tr>
<tr class="memdesc:a17a840d2cf3ad36cb97ae5f72ec2aae6"><td class="mdescLeft">&#160;</td><td class="mdescRight">get the initial alignments <br /></td></tr>
<tr class="separator:a17a840d2cf3ad36cb97ae5f72ec2aae6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab0181ab18dcdcdb1c71b328e2bceca5a"><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1WindowedAttention.html#ab0181ab18dcdcdb1c71b328e2bceca5a">__call__</a> (self, query, state)</td></tr>
<tr class="memdesc:ab0181ab18dcdcdb1c71b328e2bceca5a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Score the query based on the keys and values.  <a href="#ab0181ab18dcdcdb1c71b328e2bceca5a">More...</a><br /></td></tr>
<tr class="separator:ab0181ab18dcdcdb1c71b328e2bceca5a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>attention mechanism that is location aware </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="ac9db812b48e8bc8d138a63ad47457493"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac9db812b48e8bc8d138a63ad47457493">&sect;&nbsp;</a></span>__init__()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.attention.WindowedAttention.__init__ </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>num_units</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>left_window_width</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>right_window_width</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>memory</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>memory_sequence_length</em> = <code>None</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>normalize</em> = <code>False</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>probability_fn</em> = <code>None</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>score_mask_value</em> = <code>float(&quot;-inf&quot;)</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>dtype</em> = <code>None</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>name</em> = <code>'<a class="el" href="classnabu_1_1neuralnetworks_1_1components_1_1attention_1_1LocationAwareAttention.html">LocationAwareAttention</a>'</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Construct the Attention mechanism. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">num_units</td><td>The depth of the query mechanism. </td></tr>
    <tr><td class="paramname">window_width</td><td>the width of the attention window </td></tr>
    <tr><td class="paramname">memory</td><td>The memory to query; usually the output of an RNN encoder. This tensor should be shaped <code>[batch_size, max_time, ...]</code>. </td></tr>
    <tr><td class="paramname">memory_sequence_length</td><td>Sequence lengths for the batch entries in memory. If provided, the memory tensor rows are masked with zeros for values past the respective sequence </td></tr>
    <tr><td class="paramname">lengths.</td><td></td></tr>
    <tr><td class="paramname">normalize</td><td>Python boolean. Whether to normalize the energy term. </td></tr>
    <tr><td class="paramname">probability_fn</td><td>(optional) A <code>callable</code>. Converts the score to probabilities. The default istf.nn.softmax}. Other options includetf.contrib.seq2seq.hardmax} and tf.contrib.sparsemax.sparsemax}. Its signature should be: <code>probabilities = probability_fn(score)</code>. </td></tr>
    <tr><td class="paramname">score_mask_value</td><td>(optional): The mask value for score before passing into <code>probability_fn</code>. The default is -inf. Only used if <code>memory_sequence_length</code> is not None. </td></tr>
    <tr><td class="paramname">name</td><td>Name to use when creating ops. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ab0181ab18dcdcdb1c71b328e2bceca5a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab0181ab18dcdcdb1c71b328e2bceca5a">&sect;&nbsp;</a></span>__call__()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">def nabu.neuralnetworks.components.attention.WindowedAttention.__call__ </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>query</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>state</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Score the query based on the keys and values. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">query</td><td>Tensor of dtype matching <code>self.values</code> and shape <code>[batch_size, query_depth]</code>. </td></tr>
    <tr><td class="paramname">state</td><td>Tensor of dtype matching <code>self.values</code> and shape <code>[batch_size, alignments_size]</code> (<code>alignments_size</code> is memory's <code>max_time</code>).</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd></dd>
<dd>
alignments Tensor of dtype matching <code>self.values</code> and shape <code>[batch_size, alignments_size]</code> (<code>alignments_size</code> is memory's <code>max_time</code>). </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="attention_8py.html">attention.py</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>
